package com.quan.commons.config;

import com.quan.commons.filter.TraceIdContextFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TraceId过滤器配置
 */
@Configuration
public class TraceIdContextFilterConfig {

    @Bean
    public FilterRegistrationBean<TraceIdContextFilter> traceIdContextFilter() {
        FilterRegistrationBean<TraceIdContextFilter> registrationBean = new FilterRegistrationBean<>();

        TraceIdContextFilter filter = new TraceIdContextFilter();
        registrationBean.setFilter(filter);
        registrationBean.setOrder(-105);
        registrationBean.addUrlPatterns("/*");

        return registrationBean;
    }

}
